package cn.xuchunh.exam;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * 70%
 * Created by XuChunH on 2016/9/12.
 */
public class HuiWenTransform {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int length = scanner.nextInt();
        if(length == 1){
            System.out.println(0);
            return;
        }
        ArrayList<Integer> list = new ArrayList<>(length);
        for (int i = 0; i < length; i++) {
            list.add(scanner.nextInt());
        }
        System.out.println(transform(list, 0));
    }

    private static int transform(ArrayList<Integer> list, int start){
        int count = 0;
        int size = list.size();
        for (int i = start; i < size - 1; i++) {
            if(!list.get(i).equals(list.get((size - 1 - i) % size))){
                int sum = list.get(i) + list.get(i + 1);
                list.remove(i + 1);
                list.remove(i);
                list.add(i, sum);
                i--;
                size = list.size();
                count ++;
            }
        }
        return count;
    }
}
